﻿using Kanban.IDal;
using Kanban.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Kanban.Dal
{
    public class UserDal : BaseDal<UserId_仓码对应表>, IUserDAL
    {
        public UserDal()
        {
            TableName = "[UserId_仓码对应表]";
        }

        public Task<UserId_仓码对应表> GetModelAsync(string name, string pwd)
        {
            return GetModelAsync($"UserNo = '{name}' AND Password = '{pwd}'", new { UserId = name, Password = pwd });
        }

        public Task<Tuple<IList<object>, int>> GetModelsByPageAsync(string search, int pageSize, int pageIndex)
        {
            string whereSql = "1 = 1";
            if (!string.IsNullOrEmpty(search))
            {
                whereSql += $" AND (UserNo LIKE '%{search}%')";
            }
            return GetModelsByPageAsync("*", whereSql, "Id DESC", pageSize, pageIndex);
        }
    }
}
